package com.xxf.aynu.parking;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Rossoneri on 2017/5/11 0011.
 */
public class activity_park extends Activity {
    TextView txt1;
    TextView txt2;
    TextView txt3;
    TextView txt4;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.fragment_weizhifu);
        setContentView(R.layout.activity_address);
        txt1=(TextView)findViewById(R.id.txt_tianjiao);
        txt1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showNormalDialog();
            }
        });
        txt2=(TextView)findViewById(R.id.txt_xian);
        txt2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showNormalDialog2();
            }
        });

        txt3=(TextView)findViewById(R.id.txt_jindu);
        txt3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showNormalDialog3();
            }
        });
        txt4=(TextView)findViewById(R.id.txt_jindu2);
        txt4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showNormalDialog4();
            }
        });



       /* ListView listView = (ListView) findViewById(R.id.address_list);
        List<String> mList=new ArrayList<String>();
        mList.add("天骄华府-地下停车场 ");
        listView.setAdapter(new  lvAdapter(mList, activity_park.this));*/

       /* ListView listView1 = (ListView) findViewById(R.id.adorder_list);
        List<String> mList1=new ArrayList<String>();
        mList1.add("天骄华府-地下停车场\n订单时间: 017/5/11 18:51\n订单号: 00000019\n订单金额: 5元");
        listView1.setAdapter(new lvAdapter(mList1,activity_park.this));*/



       /* listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                switch (position)
                {
                    case 0:showNormalDialog();
                        break;
                    case 1: showNormalDialog2();
                        break;
                    case 2:showNormalDialog3();
                        break;
                    case 3:showNormalDialog4();
                        break;

                }
            }
        });*/
    }
    public void showNormalDialog(){
        /* @setIcon 设置对话框图标
         * @setTitle 设置对话框标题
         * @setMessage 设置对话框消息提示
         * setXXX方法返回Dialog对象，因此可以链式设置属性
         */
        final AlertDialog.Builder normalDialog = new AlertDialog.Builder(activity_park.this);
        normalDialog.setIcon(R.drawable.dia);
        normalDialog.setTitle("弦歌大道与文鼎路交叉口西100米");
        normalDialog.setMessage("确认下单?");
        normalDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Intent intent=new Intent();
                intent.setClass(getApplicationContext(), activity_pay.class);
                startActivity(intent);



            }
        });
        normalDialog.setNegativeButton("关闭", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                //...To-do
            }
        });
        // 显示
        normalDialog.show();
    }
    public void showNormalDialog2(){
        /* @setIcon 设置对话框图标
         * @setTitle 设置对话框标题
         * @setMessage 设置对话框消息提示
         * setXXX方法返回Dialog对象，因此可以链式设置属性
         */
        final AlertDialog.Builder normalDialog = new AlertDialog.Builder(activity_park.this);
        normalDialog.setIcon(R.drawable.dia);
        normalDialog.setTitle(" 东风路东50米");
        normalDialog.setMessage("确认下单?");
        normalDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Intent intent=new Intent();
                intent.setClass(getApplicationContext(), activity_pay.class);
                startActivity(intent);




            }
        });
        normalDialog.setNegativeButton("关闭", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                //...To-do
            }
        });
        // 显示
        normalDialog.show();
    } public void showNormalDialog3(){
        /* @setIcon 设置对话框图标
         * @setTitle 设置对话框标题
         * @setMessage 设置对话框消息提示
         * setXXX方法返回Dialog对象，因此可以链式设置属性
         */
        final AlertDialog.Builder normalDialog = new AlertDialog.Builder(activity_park.this);
        normalDialog.setIcon(R.drawable.dia);
        normalDialog.setTitle(" 安阳市文峰区弦歌大道北50米");
        normalDialog.setMessage("确认下单?");
        normalDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Intent intent=new Intent();
                intent.setClass(getApplicationContext(), activity_pay.class);
                startActivity(intent);

            }
        });
        normalDialog.setNegativeButton("关闭", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                //...To-do
            }
        });
        // 显示
        normalDialog.show();
    }

    public void showNormalDialog4(){
        /* @setIcon 设置对话框图标
         * @setTitle 设置对话框标题
         * @setMessage 设置对话框消息提示
         * setXXX方法返回Dialog对象，因此可以链式设置属性
         */
        final AlertDialog.Builder normalDialog = new AlertDialog.Builder(activity_park.this);
        normalDialog.setIcon(R.drawable.dia);
        normalDialog.setTitle(" 安阳市文峰区弦歌大道北50米");
        normalDialog.setMessage("确认下单?");
        normalDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                Intent intent=new Intent();
                intent.setClass(getApplicationContext(), activity_pay.class);
                startActivity(intent);

            }
        });
        normalDialog.setNegativeButton("关闭", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                //...To-do
            }
        });
        // 显示
        normalDialog.show();
    }


    //ListView 数据绑定
    class lvAdapter extends BaseAdapter {

        List<String> mList;
        Context mContext;

        public lvAdapter(List<String> mList, Context mContext) {
            this.mList = mList;
            this.mContext = mContext;
        }

        @Override
        public int getCount() {
            return mList != null ? mList.size() : 0;
        }

        @Override
        public Object getItem(int position) {
            return mList != null ? mList.get(position) : 0;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView mTvMsg = null;
            if (convertView == null) {

                convertView = LayoutInflater.from(mContext).inflate(R.layout.layout_item_lv, parent, false);
                mTvMsg = (TextView) convertView.findViewById(R.id.tv_msg);
            }

            String msg = mList.get(position);
            if (msg != null) {
                mTvMsg.setText(msg);
            }

            return convertView;
        }
    }




}

